using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace UNGDUNG
{
    public partial class frmView : Form 
    {
        public frmView()
        {
            InitializeComponent();
        }
        clsDatabases cls;
        HelpProvider hp;
        private void frmView_Load(object sender, EventArgs e)
        {
            AssignHelp();
            cls = new clsDatabases("");
            ShowView(clsStatic.strMasterInput ,clsStatic.strInput);
        }
        void ShowView(string database,string name)
        {            
            richTextBox1.Text = cls.GetText( database,"["+name+"]");
        }
        void AssignHelp()
        {
            hp = new HelpProvider();
            hp.HelpNamespace = Application.StartupPath.Replace(@"\bin\Debug", "") + @"\help.htm";
            hp.SetHelpKeyword(this.button3, "Database");
            hp.SetHelpNavigator(this.button3, HelpNavigator.Index);
            hp.SetHelpString(this.button3, "Database");
            hp.SetShowHelp(this.button3, true);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                cls.ExecuteSQL(richTextBox1.Text);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message );
            }
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            button1.Enabled = true;
        }
    }
}